<template>
  <div v-show="props.compType === 'text'">
    <div v-show="props.fieldType === 'CombineValue'">
      <el-form-item label="标题" labelWidth="40px">
        <el-input class="input" v-model="props.text"></el-input>
      </el-form-item>
      <el-form-item label="类型" labelWidth="40px">
        <el-radio-group v-model="props.valType" @change="getline">
          <el-radio-button label="date">时间</el-radio-button>
          <el-radio-button label="num">数字</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="选项" labelWidth="40px">
        <el-checkbox-group v-model="props.fieldNames">
          <el-checkbox
            v-for="city in itemlist"
            :label="city.label"
            :key="city.id"
            >{{ city.label }}</el-checkbox
          >
        </el-checkbox-group>
      </el-form-item>
       <el-form-item label="表达式" labelWidth="60px">
        <el-input class="input" type="textarea" v-model="props.function" placeholder="请输入聚合表单式" style="width:100% !important"></el-input>
      </el-form-item>
    </div>
  </div>
</template>
<script>
import { changeId } from "../mixin";
export default {
  name: "textConfig",
  props: ["props", "list"],
  created() {
    if (this.props.privateInfo != undefined) {
      console.log(JSON.parse(this.props.privateInfo));
      this.props.valType = JSON.parse(this.props.privateInfo).valType;
      this.props.fieldNames = JSON.parse(this.props.privateInfo).fieldNames;
    }
    this.chelisy();
  },
  watch: {
    props: {
      handler(val) {
        let list = JSON.parse(JSON.stringify(this.list));
        if (val.valType === "date") {
          const finvalue = list.filter((val) => {
            return (
               val.fieldType === "InputDate"
            );
          });
          this.itemlist = finvalue;
          this.max = 2;
        } else {
          const finvalue = list.filter((val) => {
            return val.fieldType === "InputNumber";
          });
          this.itemlist = finvalue;
          this.max = 100000;
        }
      },
      deep: true,
    },
  },
  data() {
    return {
      ishow: false,
      itemlist: [],
      max: 2,
    };
  },
  mixins: [changeId],
  methods: {
    chagejr() {},
    handlerChangeSize(val) {
      this.props.size = val + "";
    },
    handclick() {},
    getline() {
      this.props.fieldNames = [];
      this.chelisy();
    },
    chelisy() {
      let list = JSON.parse(JSON.stringify(this.list));
      if (this.props.valType === "date") {
        const finvalue = list.filter((val) => {
          return (
             val.fieldType === "InputDate"
          );
        });
        this.itemlist = finvalue;
      } else {
        const finvalue = list.filter((val) => {
          return val.fieldType === "InputNumber";
        });
        this.itemlist = finvalue;
      }
      console.log( this.itemlist)
    },
    handlerChangeBold(val) {
      this.props.bold = val + "";
    },
  },
};
</script>
